package labox.innovation.gameserver.model;

import java.io.DataOutputStream;
import java.util.HashMap;

import org.w3c.dom.Element;

public class Point {

	private int exchangeID;

	private ExchangeScene es;

	public Point() {
		es = new ExchangeScene();
		es.moveToSceneID = -1;
	}

	private void setExchangeSceneID(int id) {
		es.moveToSceneID = id;
	}

	private void setExchangeSceneXY(int x, int y) {
		es.moveToSceneX = x;
		es.moveToSceneY = y;
	}

	public int getExchangeID() {
		return exchangeID;
	}

	public int getExchangeSceneID() {
		return es.moveToSceneID;
	}

	public int getExchangeSceneX() {
		return es.moveToSceneX;
	}

	public int getExchangeSceneY() {
		return es.moveToSceneY;
	}

	public static final void fromXML(Element e, HashMap<Integer, Point> _pool,
			DataOutputStream dos) throws Exception {
		Point p = new Point();
		p.exchangeID = Integer.parseInt(e.getAttribute("p1_exid"));
		p.setExchangeSceneID(Integer.parseInt(e.getAttribute("p1_movid")));
		p.setExchangeSceneXY(Integer.parseInt(e.getAttribute("p1_movx")),
				Integer.parseInt(e.getAttribute("p1_movy")));
		_pool.put(p.exchangeID, p);
		dos.writeShort(Integer.parseInt(e.getAttribute("p1x")));
		dos.writeShort(Integer.parseInt(e.getAttribute("p1y")));

		p = new Point();
		p.exchangeID = Integer.parseInt(e.getAttribute("p2_exid"));
		p.setExchangeSceneID(Integer.parseInt(e.getAttribute("p2_movid")));
		p.setExchangeSceneXY(Integer.parseInt(e.getAttribute("p2_movx")),
				Integer.parseInt(e.getAttribute("p2_movy")));
		_pool.put(p.exchangeID, p);
		dos.writeShort(Integer.parseInt(e.getAttribute("p2x")));
		dos.writeShort(Integer.parseInt(e.getAttribute("p2y")));
	}
}
